﻿@model IEnumerable<ToDoListClient.Models.ToDoItem>

@{
    ViewData["Title"] = "Index";
}

<h2>Index</h2>

<p>
    <a asp-action="Create">Create New</a>
</p>
<p> Tasks assigned to signed-in User</p>
<table class="table table-bordered">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Id)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Title)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.AssignedBy)
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item in Model)
        {
            if (item.AssignedTo == TempData["SignedInUser"].ToString())
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.Title)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.AssignedBy)
                    </td>
                </tr>
            }
        }
    </tbody>
</table>
<p>Tasks created by signed-in User</p>
<table class="table table-bordered">
    <thead>
        <tr>
            <th>
                @Html.DisplayNameFor(model => model.Id)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.Title)
            </th>
            <th>
                @Html.DisplayNameFor(model => model.AssignedTo)
            </th>
            <th>
                Actions
            </th>
        </tr>
    </thead>
    <tbody>
        @foreach (var item2 in Model)
        {
            if (item2.AssignedBy == TempData["SignedInUser"].ToString())
            {
                <tr>
                    <td>
                        @Html.DisplayFor(modelItem => item2.Id)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item2.Title)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item2.AssignedTo)
                    </td>
                    <td>
                        @Html.ActionLink("Edit", "Edit", new { id = item2.Id }) |
                        @Html.ActionLink("Delete", "Delete", new { id = item2.Id })
                    </td>
                </tr>
            }
        }
    </tbody>
</table>